package com.xiexie.config.controller;

import org.springframework.beans.factory.annotation.Value;
import org.springframework.cloud.context.config.annotation.RefreshScope;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @Description
 * @Date 2022-04-12 11:26
 * @Author xie
 */
@RestController
@RequestMapping("/config")
// @Value注解可以获取到配置中心的值，但是无法动态感知修改后的值，需要利用@RefreshScope注解
@RefreshScope
public class ConfigController {

    @Value("${user.name}")
    private String username;

    @Value("${user.config}")
    private String config;

    @RequestMapping("/test")
    public String test() {
        return "username: " + username + "; config: " + config;
    }
}
